package org.xgj.zhangben.action.user;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.xgj.zhangben.BaseAction;
import org.xgj.zhangben.service.user.UserService;

@SuppressWarnings("serial")
@Controller
@Scope("prototype")
@ParentPackage("zhangben-package")
@Namespace("/user")
@Results( {
		@Result(name = "input", location = "/login.jsp"),
		@Result(name = "loginSuccess", type = "redirect", location = "/main.jsp"),
		@Result(name = "loginFaild", type = "jump", params = { "type", "inner",
				"url", "index.jsp", "title", "登录失败" }),
		@Result(name = "registerSuccess", type = "redirect", location = "/main.jsp"),
		@Result(name = "registerFaild", type = "jump", params = { "type",
				"inner", "url", "index.jsp", "title", "注册失败" }),
		@Result(name = "logout", type = "redirect", location = "/index.jsp") })
public class UserAction extends BaseAction {
	@Resource
	private UserService userService;

	private UserVO userVO = new UserVO();

	@Action("/base")
	public String execute() throws Exception {
		return INPUT;
	}

	/**
	 * 登录
	 * 
	 */
	public String logout() throws Exception {
		return userService.logout();
	}

	/**
	 * 登陆
	 * 
	 * @return
	 * @throws Exception
	 */
	public String login() throws Exception {
		return userService.login();
	}

	/**
	 * 注册
	 * 
	 * @return
	 * @throws Exception
	 */
	public String register() throws Exception {
		return userService.register();
	}

	public UserVO getUserVO() {
		return userVO;
	}
}
